/**
* @namespace minjs.Date
*
*/
minjs.Date = function(value){
	var d;
	var type = typeof(value);
	if(type != "undefined"){
		if(type == "String"){
			d = new Date(Date.parse(value));
		} else {
			d = new Date(value);
		}
	} else {
		d = new Date();
	}
	d.toString = function(format){
		if(typeof(format) != "undefined"){
			function pad(s){
				if(s.length == 1)
					return "0" + s;
				else return s;
			}		
			switch(format){
			case "m/d/y":
				return this.getMonth() + 1 + "/" + this.getDate() + "/" + String(this.getFullYear()).substr(2,2);
			case "mm/dd/yy":
				return pad(String(this.getMonth() + 1)) + "/" + pad(String(this.getDate())) + "/" + pad(String(this.getFullYear()).substr(2,2));
			case "dd.mm.yy":
				return pad(String(this.getDate())) + "." + pad(String(this.getMonth() + 1)) + "." + pad(String(this.getFullYear()).substr(2,2));
			case "dd.mm.yyyy":
				return pad(String(this.getDate())) + "." + pad(String(this.getMonth() + 1)) + "." + this.getFullYear();
			case "dd/mm/yyyy":
				return pad(String(this.getDate())) + "/" + pad(String(this.getMonth() + 1)) + "/" + this.getFullYear();	
			default:
				return Date.prototype.toString.call(this);
			}
		} else return Date.prototype.toString.call(this);	
	}
	return d;
}

/**
* @namespace minjs.Number
*
*/
minjs.Number = function(value){
	var n;
	if(typeof(value) != "undefined"){
		n = new Number(value);
	} else {
		n = new Number();
	}
	n.toString = function(format){
		if(typeof(format) != "undefined"){			
			var str = this.toFixed(format.fractionDigits);
			if(format.thousandSeparator){
				var point = str.indexOf(".");
				if(point == -1){
					point = str.indexOf(",");
					if(point == -1)
						point = str.length;
				}
				var div = 10000;
				var val = this.valueOf();
				var idx = 1;
				while(val / div > 1){
					str = str.slice(0, point - 3 * idx) + " " + str.slice(point - 3 * idx, str.length);
					idx++;
					div *= 1000;
				}					
			}				
			return str;
			
		} else return Number.prototype.toString.call(this);
	}
	return n;
}

